# delimit;
set more off;

infix ID           1-5
 COMPDATE          6-11 
 REPNUM           12-13
 FIPSST           35-36
 MSACODE          37-41
 TYPE                42
 STRATUM          43-44 
 FORM                45
 GENFORM             49
 SEX                 50
 S1                  51
 S2                  52
 Q1A              53-54 
 Q1B              55-56 
 Q1C              57-58 
 Q2A              59-60 
 Q2B              61-62 
 Q2C              63-64 
 Q3A                 65 
 Q3B                 66 
 Q3C                 67 
 Q3D                 68 
 Q3E                 69 
 Q3F                 70 
 Q4D1             71-72 
 Q4D2             73-74 
 Q4D3             75-76 
 Q4D4             77-78 
 Q4E1F1           79-80 
 Q4E2F1           81-82 
 Q4E3F1           83-84 
 Q4E4F1           85-86 
 Q4F1F2           87-88 
 Q4F2F2           89-90 
 Q4F3F2           91-92 
 Q4F4F2           93-94 
 Q5                  95 
 Q6                  96  
 Q7                  97 
 Q8                  98 
 Q9                  99 
 Q10                 100
 Q11                 101
 Q12AA               102
 Q12BA               103
 Q12ABF1             104
 Q12BBF1             105
 Q12ACF2             106
 Q12BCF2             107
 Q13                 108
 Q14A                109
 Q14B                110
 Q14C                111
 Q14D                112
 Q15                 113
 Q16                 114
 Q17                 115
 Q18                 116
 Q19F1               117
 Q19F2               118
 Q20A                119
 Q20B                120
 Q20CF1              121
 Q20DF2              122
 Q21AF1              123
 Q21BF1              124
 Q21CF2              125
 Q21DF2              126
 Q22AF1              127
 Q22BF1              128
 Q22CF1              129
 Q22DF1              130
 Q22EF1              131
 Q22FF2              132
 Q22GF2              133
 Q22HF2              134
 Q22IF2              135
 Q22JF2              136
 Q23AF1              137
 Q23BF1              138
 Q23CF1              139
 Q23DF1              140
 Q23EF1              141 
 Q23FF2              142
 Q23GF2              143
 Q23HF2              144
 Q23IF2              145
 Q23JF2              146
 Q24A                147
 Q24B                148
 Q24C                149
 Q24D                150
 Q24E                151
 Q24F                152
 Q24G                153
 Q25                 154
 Q26A1F1             155
 Q26A2F1             156
 Q26A3F1             157
 Q26A4F1             158
 Q26A5F2             159
 Q26A6F2             160
 Q26A7F2             161
 Q26A8F2             162
 Q26B1F1             163
 Q26B2F1             164
 Q26B3F1             165
 Q26B4F1             166
 Q26B5F2             167
 Q26B6F2             168
 Q26B7F2             169
 Q26B8F2             170
 Q27A                171
 Q27B                172
 Q27C                173
 Q27DF1              174
 Q27EF1              175
 Q27FF2              176
 Q28AF1              177
 Q28BF1              178
 Q28CF1              179
 Q28DF1              180
 Q28EF2              181
 Q28FF2              182
 Q28GF2              183
 Q28HF2              184
 Q29                 185
 Q30A1F1             186 
 Q30A2F1             187
 Q30A3F1             188
 Q30A4F1             189
 Q30A5F2             190
 Q30A6F2             191
 Q30A7F2             192
 Q30A8F2             193
 Q30B1F1             194
 Q30B2F1             195
 Q30B3F1             196
 Q30B4F1             197
 Q30B5F2             198
 Q30B6F2             199
 Q30B7F2             200
 Q30B8F2             201
 Q31A                202
 Q31B                203
 Q31C                204
 Q31D                205
 Q31EF1              206
 Q31FF2              207
 Q32A                208
 Q32B                209
 Q32CF1              210
 Q32DF2              211
 Q32E                212
 Q33                 213
 Q34A                214
 Q34B                215
 Q34C                216
 Q34D                217
 Q34E                218
 Q35                 219
 Q36                 220
 Q37                 221
 Q38                 222
 Q39                 223
 Q40F1               224
 Q40F2               225
 Q41A            226-227
 Q41B            228-229
 Q41C            230-231
 Q41D            232-233
 Q41E            234-235
 Q41F            236-237
 Q41G            238-239
 Q41OTH          240-241
 Q42                 242
 Q43                 243
 Q44AF1              244
 Q44BF1              245
 Q44CF1              246
 Q44DF2              247
 Q44EF2              248
 Q44FF2              249
 Q45             250-251
 Q46                 252
 Q47                 253
 Q48                 254
 Q49                 255
 age             256-257
 educ                258
 hispanic            259
 race                260
 marital             261
 kids                262
 bornagn             263
 reg1                264
 reg2                265
 partyad             266
 home                267
 employ              268
 religion        269-270
 income          271-272
 partyun             273
 region              274
 WEIGHT2         283-287
 urs                 288
 polknow             289
 part                290
 using pewgov97.dat;
label var   Q3A     "opinion: business corporations";

label var   Q3B     "opinion: the news media";

label var   Q3C     "opinion:  the military";

label var   Q3D     "opinion: the federal government in Washington";

label var   Q3E     "opinion: your STATE government";

label var   Q3F     "opinion: your LOCAL government";

label define opinions

	1 "Very favorable"   
	2 "Mostly favorable"      
	3 "Mostly unfavorable"      
	4 "Very unfavorable"      
	5 "Never heard of"     
	6 "Can't rate"   ;
	
foreach var in A B C D E F {;
	label values Q3`var' opinions;
	};

recode Q3A (5 6=.)(1=4)(2=3)(3=2)(4=1), gen(opbusin);
recode Q3B (5 6=.)(1=4)(2=3)(3=2)(4=1), gen(opnews);
recode Q3C (5 6=.)(1=4)(2=3)(3=2)(4=1), gen(opmilit);
recode Q3D (5 6=.)(1=4)(2=3)(3=2)(4=1), gen(opfed);
recode Q3E (5 6=.)(1=4)(2=3)(3=2)(4=1), gen(opst);
recode Q3F (5 6=.)(1=4)(2=3)(3=2)(4=1), gen(oploc);
	
	
label define opinions_rev

	4 "Very favorable"   
	3 "Mostly favorable"      
	2 "Mostly unfavorable"      
	1 "Very unfavorable"  ;
 
foreach var in busin news milit fed st loc {;
	label values op`var' opinions_rev;
	}; 
      
forvalues num=1/4 {;         
	label var Q4D`num' "Explanation Open-ended: the federal government in Washington";
	};

label define Q4Dopen 
1 "Representatives don't represent the people"
2 "Representatives say one thing and do another"
3 "Too much government spending/Spend money frivolously"
4 "Politicians are dishonest/crooks"
5 "Taxes are too high"
6 "The government doesn't pay attention to/care about the
   people/government is out of touch with average citizens"
7 "Needs/opinions of the people not represented in the government"
8 "They are only out for themselves/for their own personal gain"
9 "Clinton is doing a good job"
10 "They have good intentions/Trying/Doing the best they can"
11 "Better than other countries"
12 "General satisfaction/No complaints"
13 "Economy is strong"
14 "Like Clinton's policies/Like a specific policy"
15 "Reinventing initiatives/new approaches to governing are
	working/The government is doing things better these days"
16 "Not making much progress solving national problems"
17 "Federal government can't get anything done/Too much gridlock"
18 "Government officials/politicians are inept/don't know what
	they're doing"
19 "Government is too big/There's too much government"
20 "Dislike government policies in general/Dislike a specific policy"
21 "Government is inefficient"
22 "Government is mismanaged"
23 "Government has no morals"
24 "Government has downsized too much and has cut important
	programs/services"
25 "Spend too much on foreign countries"
26 "Government interferes too much/is too intrusive/encroaches on
	individual and states' rights"
27 "Don't like Bill Clinton"
28 "Specific mention of Waco or Ruby Ridge"
29 "Things aren't going well in the country (generally)"
30 "Government has the wrong priorities"
31 "General negative (I'm not satisfied)"
32 "Positive performance evaluation (PPE)"
33 "Security/Strong defense"
34 "Peace Balance of power is good"
36 "Enjoy freedom/Democracy"
37 "Law enforcement/judicial system"
38 "Budget"
39 "Education"
40 "Bipartisan/Parties working together"
41 "Positive personal experience"
42 "Specific mention of IRS-negative"
43 "Biased media"
44 "Education-negative"
45 "Personal experience-negative"
46 "Scandals"
47 "Welfare system-negative"
48 "Court system/Judicial system-negative"
49 "Government too powerful"
50 "Lack of leadership/Bad leadership/No leadership"
51 "Special interest influence"
52 "Too liberal"
53 "Campaign finance system"
54 "Too partisan"
55 "Too much politics"
88 "Other"
99 "DK/NA";

forvalues num=1/4 {;
	label values Q4D`num' Q4Dopen;
   };

forvalues num=1/4 {;         
	label var Q4E`num'F1 "Explanation Open-ended: your STATE government";
	};

label define Q4Eopen	
1 "Don't address environmental issues"
2 "Pay for roads/highways"
3 "Politicians are corrupt"
4 "Taxes are too high"
5 "They could do a better job"
6 "They don't teach spiritual/moral/family values"
7 "Don't agree with the way they handle issues (i.e. crime,
	divorce, welfare)"
8 "Lack of concern for education"
9 "Not helping people as much as they could"
10 "Unresponsive/Slow to respond to needs/concerns"
11 "People only there for personal gain"
12 "On the road to recovery/It has improved"
13 "More approachable on the state level/not as large/more responsive than federal government"
14 "Doing the best they can"
15 "Represent the interests of the people/More in touch"
16 "Governor is doing a good job/ Like the governor"
17 "Government is working well"
18 "They pay for schools/education"
19 "Helping with the employment situation"
20 "We have more control at this level/Can vote them out"
21 "Don't like the governor"
22 "State has cut back on too many services"
23 "Spends too much"
24 "General negative (I'm not satisfied)"
25 "Positive performance evaluation (PPE)"
26 "Strong economy"
27 "Taxes are lower/reasonable"
28 "Don't interfere in my life"
29 "Strong leadership"
30 "Like specific policy/policies"
31 "Personal experience/contact"
32 "Welfare reform"
33 "Don't like specific policy/policies"
34 "Welfare System-negative"
35 "Immigration"
36 "Too much crime"
37 "Personal experience-negative"
38 "Too liberal"
39 "Court system/Judicial system-negative"
40 "Lack of leadership/Bad leadership/No leadership"
41 "Wrong priorities"
42 "Need better education"
87 "General satisfaction/No complaints"
88 "Other"
99 "DK/NA";

 forvalues num=1/4 {;
	label values Q4E`num'F1 Q4Eopen;
	};  
 
label var Q12AA      "Effect on day-to-day life: Federal gov";
label var Q12BA      "Effect positive or negative: Federal gov";
label var Q12ABF1    "Effect on day-to-day life: State gov";
label var Q12BBF1    "Effect positive or negative: State gov";
label var Q12ACF2    "Effect on day-to-day life: State gov";
label var Q12BCF2    "Effect positive or negative: Local gov";
           
label define effect
          1 "Great effect"
          2 "Some effect"
          3 "None" 
          4 "Don't know"
          5 "Refused";
 
label define effect2		   
          1 "Positive"
          2 "Negative"
          3 "Neither (VOL.)"
          4 "Don't know"
          5 "Refused";
		  
label define effect_rev
          3 "Great effect"
          2 "Some effect"
          1 "None";
 
label define effect2_rev		   
          1 "Positive"
          -1 "Negative"
          0 "Neither (VOL.)";

recode Q12AA (1=3)(2=2)(3=1)(4 5=.), gen(ef1fed);	  
recode Q12AB (1=3)(2=2)(3=1)(4 5=.), gen(ef1st);
recode Q12AC (1=3)(2=2)(3=1)(4 5=.), gen(ef1loc);

recode Q12BA (1=1)(2=-1)(3=0)(4 5=.), gen(ef2fed);	  
recode Q12BB (1=1)(2=-1)(3=0)(4 5=.), gen(ef2st);
recode Q12BC (1=1)(2=-1)(3=0)(4 5=.), gen(ef2loc);	
	  
foreach var in A B C {;		  
	label values Q12A`var' effect;
	label values Q12B`var' effect2;	
	};
	
label values ef1* effect_rev;
label values ef2* effect2_rev;	

label var	Q20A   "trust and confidence in fed gov handling national problems";
label var	Q20B   "trust and confidence in fed gov handling international problems";
label var	Q20CF1  "trust and confidence in state gov handling state problems";
label var	Q20DF2  "trust and confidence in local gov handling local problems";

label define trstconf
	1 "Great deal"     
	2 "Fair amount"       
	3 "Not very much"          
	4 "None at all"            
	5 "Don't know"      
	6 "Refused";

label define trstconf_rev
	4 "Great deal"     
	3 "Fair amount"       
	2 "Not very much"          
	1 "None at all";            

 
label values Q20* trstconf;

recode Q20A (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(trfednatnl);
recode Q20B (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(trfedintnl);
recode Q20CF1 (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(tr_state);
recode Q20DF2 (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(tr_local);
 
label values tr_* trstconf_rev;
         
 

label var  Q34A    "how often: watch news on television" ;
label var  Q34B    "how often: read newspapers";
label var  Q34C    "how often: listen to news on the radio";
label var  Q34D    "how often: listen to talk radio";
label var  Q34E    "how often: use a computer to go online";

label define howoften
	1 "Regularly"
	2 "Sometimes"  
	3 "Hardly ever"  
	4 "Never"
	5 "Don't know"    
	6 "Refused" ;
 
label define howoften_rev
	4 "Regularly"
	3 "Sometimes"  
	2 "Hardly ever"  
	1 "Never" ;

recode Q34A (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(howoft_tvnews);
recode Q34B (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(howoft_newspap);
recode Q34C (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(howoft_radio);
recode Q34D (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(howoft_talkrad);
recode Q34E (4=1)(3=2)(2=3)(1=4)(5 6=.), gen(howoft_onlinenew);

label values Q34* howoften;
label values howoft_* howoften_rev;
	
recode Q37 	(1=4 "Always")
			(2=3 "Nearly always")
			(3=2 "Part of the time")
			(4=1 "Seldom")
			(6=0 "Never")
			(5 7 8=.), gen(vote_freq);
			
label var vote_freq "How often would you say you vote? (Q37)";

recode Q42 (1=1 "Favor")(2=0 "Oppose")(3 4=.), gen(secede);

label var secede "Favor or oppose allowing secession (Q42)";

recode Q45 (9=0 "No")(1/8=1 "Yes")(10 11=.), gen(govworker);
label var govworker "Do you work family member work for gov? (Q45)";

recode Q6 (1=1)(2=0)(8/9=.), gen(trfedbas);
	lab var trfedbas "Would you say you basically trust fed gov? Q6";

recode Q14A (1=0)(2=1)(3/9=.), gen (soctrust);
	lab var soctrust "Q14a in Sept 1997, slightly different from Mid-Nov C3";

recode bornagn (1=1)(2=0)(3=.);

recode age (98/99=.), gen(r_age);

recode educ (8/9=.), gen(r_educ);

recode SEX (1=1)(2=0), gen(r_male);

recode hisp (1=1)(2=0)(3/9=.), gen(r_hisp);

recode race (1=1)(2/4=0)(5/6=.), gen(r_white);
   replace r_white=0 if r_hisp==1;

recode race (2=1)(1=0)(3/4=0)(5/6=.), gen(r_black);
   replace r_black=0 if r_hisp==1;
   
recode race (3=1)(1 2=0)(4=0)(5/6=.), gen(r_asian);
   replace r_asian=0 if r_hisp==1;   

recode marital (1=1)(2/5=0)(7=.), gen(married);
recode marital (1=0)(2/3=1)(4/5=0)(7=.), gen(div_sep);
recode marital (1/3=0)(4=1)(5=0)(7=.), gen(widowed);
recode marital (1/4=0)(5=1)(7=.), gen(single);

recode income (9/10=.), gen(r_income);

recode partyun (1=1)(2/5=0)(6/7=.), gen(gop);
recode partyun (1=0)(2=1)(3/5=0)(6/7=.), gen(dem);
recode partyun (1/2=0)(3/5=1)(6/7=.), gen(ind);

recode partyun (1=1 "Republican")(2=5 "Democrat")(3/5=3)(6/7=.), gen(partyid);
replace partyid=2 if partyid==3 & partyad==1;
replace partyid=3 if partyid==3 & partyad==3;
replace partyid=3 if partyid==3 & partyad==4;
replace partyid=4 if partyid==3 & partyad==2;

recode home (1=1)(2/3=0)(4/5=.), gen(ownhome);

recode employ (3=1)(1/2=0)(4/5=.), gen(unemploy);

recode reg1
           (1=1 "Yes, registered")
           (2=0 "No, not registered")
           (3 4=. ), gen(registered);

gen year=1997;
gen year1997=1;

rename FIPSST fips;
rename WEIGHT2 weight;

keep fips partyid unemploy ownhome soctrust reg1 gop dem ind party* r_income single widowed div_sep
	married r_hisp r_black r_white r_asian r_male r_educ r_age bornagn Q4D* Q4E*
	op* tr* ef1* ef2* howoft* year weight; 

codebook fips partyid unemploy ownhome soctrust reg1 gop dem ind party* r_income single widowed div_sep
	married r_hisp r_black r_male r_educ r_age bornagn 
	op* tr* ef1* ef2* howoft* year; 


 

